package com.honey.serializable;

import java.util.Properties;

import org.w3c.dom.Element;

import com.honey.configureation.holder.ConfigurationHolder;
import com.honey.configureation.xmlparser.ParseElement;
import com.honey.core.NullPlugin;
import com.honey.serializable.SerializableObjectFactory.SerializableLibraay;

public class SerializablePlugin extends NullPlugin implements ConfigurationHolder{
	
	private SerializableLibraay jsonLibrary = SerializableLibraay.ORG_JSON;
	
	@Override
	public void parserElement(Element element, Properties properties) {
	
		//jsonLibrary
		String tmp =  ParseElement.getConfiguration(element, "jsonLibrary", properties);
		if( "net.sf.json.JSONObject" .equalsIgnoreCase(tmp) ){
			jsonLibrary =  SerializableLibraay.NET_SF_JSON;
		}else if( "org.json.simple.JSONObject" .equalsIgnoreCase(tmp)){
			jsonLibrary =  SerializableLibraay.ORG_JSON_SIMPLE;
		}else if( "com.google.gson.Gson" .equalsIgnoreCase(tmp)){
			jsonLibrary =  SerializableLibraay.GOOGLE_GSON;
		}else if( "org.json.JSONObject" .equalsIgnoreCase(tmp)){
			jsonLibrary =  SerializableLibraay.ORG_JSON;
		}else if( "com.honey.toxml" .equalsIgnoreCase(tmp)){
			jsonLibrary =  SerializableLibraay.HONEY_XML;
		}
	}

	@Override
	public String toXmlElement() {
		return null;
	}

	@Override
	public void validate() {
	}

	/**
	 * @return the jsonLibrary
	 */
	public final SerializableLibraay getJsonLibrary() {
		return jsonLibrary;
	}



}
